# coding: utf-8
import csv

s=raw_input("old file:")
oldcsvfile = file(s,'rb') 
#oldcsvfile = file('d:\\temp\\bbb.csv', 'rb')

s=raw_input("new file:")
newcsvfile = file(s,'rb') 
#newcsvfile = file('d:\\temp\\aaa.csv', 'rb')

s=raw_input("Output file:")
csvfile = file(s,'wb') 
#csvfile = file('d:\\temp\\final.csv','wb')

finalwriter = csv.writer(csvfile)
newreader = csv.reader(newcsvfile)
oldreader = csv.reader(oldcsvfile)

fnd = False
signstr = ''
signstr1 = ''

for newrow in newreader:
    fnd = False
    oldcsvfile.seek(0)

    for oldrow in oldreader:
        signstr = ''
        signstr1 = ''

        if oldrow == newrow:
            fnd = True
            newrow.insert(0," ")
            break      
        
        elif(oldrow[0] == newrow[0] and oldrow[27]==newrow[27]):
            if oldrow[5]!=newrow[5]:
                signstr = signstr + 'A'
                signstr1 = signstr1 + '('+newrow[5]+'<>'+oldrow[5]+')'
            if oldrow[16]!=newrow[16]:
                signstr = signstr + 'B'
                signstr1 = signstr1 + '('+newrow[16]+'<>'+oldrow[16]+')'
            if oldrow[17]!=newrow[17]:
                signstr = signstr + 'C'
                signstr1 = signstr1 + '('+newrow[17]+'<>'+oldrow[17]+')'
            if oldrow[19]!=newrow[19]:
                signstr = signstr + 'D'
                signstr1 = signstr1 + '('+newrow[19]+'<>'+oldrow[19]+')'
            print newrow[0] + ':' + signstr + signstr1
            print '\n'
            newrow.insert(0,signstr)
#            print newrow
            fnd = True
            break

    if fnd == False:
        newrow.insert(0,"New ID")
        print newrow[0] + ':' + 'New ID'
    
    finalwriter.writerow(newrow)
            
oldcsvfile.close()
newcsvfile.close()
csvfile.close()
